<template>
  <div>
    <a-card :bordered='false'>
      <f-search-form :more='true' @searchHandler='searchHandler' :tableObj='$refs.table'
                     :global-params='{activeKey:this.activeKey}'>
        <f-search-form-item label='部门' ref='dept' name='deptId' type='select' :data='api.dept.list' valueKey='deptId'
                            label-key='deptName' style='width: 220px' :params='queryParam'/>
        <f-search-form-item label='订单编号' name='orderNo' style='width: 300px' />
        <f-search-form-item label='开始日期' type='date' name='beginDate' style='width: 240px' />
        <f-search-form-item label='结束日期' type='date' name='endDate' style='width: 240px' />
      </f-search-form>
      <f-table ref='table' size='small' rowKey='orderId' :showSetting='true' :setting-key='this.activeKey'
               :tableColumns='columns' :multiple='true' :scroll='scroll' :operator='operator' :params='queryParam'
               :api='api.hyOrder'>
          <span slot='action' slot-scope='text, record'>
            <template>
              <a @click='$refs.orderInfoDrawer.showDrawer(record)'>查看</a>
              <a-divider type='vertical' />
              <a-dropdown>
            <a class='ant-dropdown-link' v-if="text!='-'">更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
                <a-menu-item>
                <a href='javascript:;' @click="initOrder(record)">同步订单</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
            </template>
          </span>
      </f-table>
      <order-info-drawer ref='orderInfoDrawer'></order-info-drawer>
    </a-card>
  </div>
</template>

<script>
import api from "./js/api"
import OrderInfoDrawer from "./order_info1_drawer"

export default {
  name: "ordertable1",
  components: {
    OrderInfoDrawer
  },
  data() {
    let me = this
    //操作按钮
    let operator = []
    // operator.push({
    //   name: '添加订单',
    //   icon: 'plus',
    //   that: this,
    //   handler: function(table, that) {
    //     that.$refs.drawer.showDrawer()
    //   }
    // })
    operator.push({
      name: "删除",
      icon: "delete",
      batch: true,
      handler: function(table) {
        table.remove()
      }
    })
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {
        companyId: "",
        isFlp:1
      },
      superAdmin: this.superAdmin,
      processImageVisible: false,
      scroll: { x: true },
      // 表头
      columns: [
        {
          title: "操作",
          width: "100px",
          dataIndex: "action",
          scopedSlots: { customRender: "action" }
        },
        {
          title: "单据日期",
          align: "left",
          width: "150px",
          dataIndex: "orderDate",
        },
        {
          title: "订单编号",
          align: "left",
          width: "140px",
          dataIndex: "orderNo"
        },
        {
          title: "单位名称",
          align: "left",
          width: "130px",
          dataIndex: "companyCode"
        },
        {
          title: "业务员",
          align: "left",
          width: "100px",
          dataIndex: "saleManName"
        },
        {
          title: "部门",
          align: "left",
          width: "80px",
          dataIndex: "deptCode"
        },
        {
          title: "发货方式",
          align: "left",
          width: "70px",
          dataIndex: "transportWay"
        },
        {
          title: "数量",
          align: "left",
          width: "140px",
          dataIndex: "saleNum"
        },
        {
          title: "销售金额",
          align: "left",
          width: "140px",
          dataIndex: "saleAmount"
        }
      ],
      operator: operator
    }
  },
  methods: {
    initOrder(record){
      this.http.confirm(this, {
        content: '确认初始化订单吗?',
        url: api.hyOrder.syncOrder,
        data: {
          orderNo: record.orderNo
        },
        success: function(me, data) {
          me.$refs['table'].refresh(false)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>